﻿$(function() {
    JSUtility.param.ClassName = "OA.Bll.Project.ProjectCashInfoPresenter";
    JSUtility.param.Options["InternalType"] = "0";
    autoResize({ dataGrid: '#Grid', callback: Initlist });

    JSUtility.window_edit = $('#Add').window({
        iconCls: 'icon-add',
        zIndex: 1000,
        draggable: true,
        resizable: false,
        shadow: true,
        inline: true,
        modal: true,
        title: '添加项目收入现金信息',
        collapsible: false,
        minimizable: false,
        maximizable: false,
        closable: true,
        width: 450,
        //height: 210,
        closed: true,
        onOpen: function() {
            $('#Add').parent().css("left", "25%");
            $('#Add').parent().next().css("left", "25%");
            $('#Add').parent().next().css("top", "25%");
            $('#Add').parent().css("top", "25%");
        }
    });
    $('#Add').show();
    JSUtility.window_edit_title = "项目收入现金信息";
    JSUtility.window_edit_form = $("#Add").find("form");
});

function refresh() {
    var contractsId = self.parent.incomeId;
    JSUtility.param.Options["IncomeId"] = contractsId;
    JSUtility.grid.datagrid({ method: "post", queryParams: { "json": $.toJSON(JSUtility.param) }, url: JSUtility.url });
}

function Initlist(size) {
    var contractsId = null;  //self.parent.payBackId; ;
    if (self.parent.IncomeId != "") {
        contractsId = self.parent.IncomeId;

        JSUtility.param.Options["IncomeId"] = contractsId;
        JSUtility.replenish = function() {
            $("#IncomeId").val(contractsId);
        };
        $("#IncomeId").attr("readonly", "readonly");
    }
    //    if (self.parent.projectInfoManager) {
    //        contractsId = self.parent.parent.public_ids.options["ProjectPayBackId"];
    //    } else {
    //        contractsId = self.parent.public_ids.options["ProjectPayBackId"];
    //    }

    JSUtility.param.Method = "Search";

    JSUtility.grid = $('#Grid').datagrid({
        tilte: '项目收入现金信息',
        iconCls: 'icon-save',
        width: size.width,
        height: size.height,
        pageSize: Math.round(size.height / 25),
        pageList: [Math.round(size.height / 25)],
        nowrap: true,
        striped: true,
        url: JSUtility.url,
        queryParams: { "json": $.toJSON(JSUtility.param) },
        sortOrder: 'desc',
        idField: 'Id',
        frozenColumns: [[{ title: '编号', field: 'Id', width: 50, sortable: true}]],
        columns: [[
                            { title: '回款收入编号', field: 'IncomeId', width: 80 },
                            { title: '单位名称', field: 'Company', width: 80 },
                            { title: '到账时间', field: 'CashTime', width: 80 },
                            { title: '到账金额', field: 'CashAmount', width: 80 },
                            { title: '累计收入', field: 'TotalCash', width: 80 }
                        ]],
        pagination: true,
        rownumbers: true,
        singleSelect: true,
        toolbar: [
                    {
                        text: '添加',
                        iconCls: 'icon-add',
                        handler: JSUtility.add
                    }, '-',
                    {
                        text: '修改',
                        iconCls: 'icon-edit',
                        handler: JSUtility.update
                    }, '-',
                    {
                        text: '删除',
                        iconCls: 'icon-remove',
                        handler: JSUtility.del
                    }, '-',
                    {
                        text: '查询',
                        iconCls: 'icon-search',
                        handler: JSUtility.search
                    }
                  ]
    });
}
